<?
	$id=0;
	$mod = $_GET['mod'];
	$title_add = "Account";
	if(isset($_GET['id']))
	{
		$id=$_GET['id'];
		$db = new MySQL();
		$sql = $db->select("select * from account where id='$id'");
		if ($db->numrows($sql)>0)	
		$row = $db->fetch($sql);
		$title_add = "Account";
	}
?>

<script type="text/JavaScript">
	function checkinput()
	{
		if(document.frmedit.txtemail.value=="")
		{
			alert('Please enter email address for account!');
			document.frmedit.txtemail.focus();
			return false;
		}	
		else if(!isEmail(document.frmedit.txtemail.value)) 
		{
			alert("Email address isn't corect. Please enter email for account again!");
			document.frmedit.txtemail.focus();
			return false;
		}
		
		return true;			 
	}
	 
	function save(id)
	{
		var frm=document.frmedit;
		if(checkinput())
		{
			if(id!=0)
				frm.action="?mod=<?=$mod?>&act=process&id="+id;
			else 
				frm.action="?mod=<?=$mod?>&act=process";
			frm.method="POST";
			frm.submit();
		}
	}
	function resetform()
	 {
	   document.frmedit.reset();
	   
	 }
</script>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
	  <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td width="34"><img src="<?=APPLICATION_SITEADMIN_URL?>images/cor_data_top_l.gif" alt="tl" width="34" height="19" /></td>
			<td class="toptborder">&nbsp;</td>
			<td width="20"><img src="<?=APPLICATION_SITEADMIN_URL?>images/cor_data_top_r.gif" alt="tr" /></td>
		  </tr>
	  </table></td>
	</tr>
	<tr>
	  <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td width="10" class="leftborder">&nbsp;</td>
			<td>
			
			
			<table width="100%" border="0" cellpadding="0" cellspacing="2" class="dataBack">
		  <tr>
			<td width="55%" height="36" class="titleOrange"><?=$title_add?></td>
			<td align="right" valign="middle" class="titleOrange">&nbsp;</td>
		  </tr>
		  <tr>
			<td height="4" colspan="2" background="images/cor_data_line1.gif"></td>
		  </tr>
		  <tr>
			<td colspan="2" class="dataBack2">
			<form name="frmedit" method="post" enctype="multipart/form-data" onSubmit="return checkinput();">
			<table width="100%" border="0" cellspacing="0">   
				  <tr>
					<td width="19%" align="right" valign="middle">Username :</td>
					<td align="left" valign="middle"><input name="txtuser" type="text" class="form_1" value="<?=$row['username']?>"  <?php if (isset($args['id'])) echo ' disabled=disabled'; ?> ></td>
				  </tr>
				  <tr>
					<td width="19%" align="right" valign="middle">Password : </td>
					<td align="left" valign="middle"><input name="txtpass" type="password" class="form_1" <?php if (isset($_GET['id'])) echo 'value="*******" disabled=disabled'; ?>></td>
				  </tr>  
				  <tr>
					<td align="right" valign="top">Email :</td>
					<td align="left" valign="top"><input name="txtemail" type="text" class="form_1" value="<?=$row['email']?>"> </td>
				  </tr>
				  
				  <tr>
					<td align="right" valign="top">Permission : </td>
					<td align="left" valign="top"><input name="rdper" type="radio" value="1" <? if($row['per']==1) echo "checked";?>>
					  Admin &nbsp;&nbsp; <input name="rdper" type="radio" value="0" <? if($row['per']==0) echo "checked";?>>
					  User</td>
				  </tr>
				  <tr>
					<td width="19%" align="right" valign="top">&nbsp;</td>
					<td align="left" valign="top">
					<img src="images/icons/save.png" onClick="save(<?=$id?>);" class="pointer" />  &nbsp;
					<img src="images/icons/reset.png" onClick="resetfrom();" class="pointer" /></td>
				</tr>
				</table>
				<input type="hidden" name="form_" value="edit">
			</form>			
			</td>
		  </tr>
		</table>
			
			
			</td>
			<td width="10" class="rightborder">&nbsp;</td>
		  </tr>
	  </table></td>
	</tr>
	<tr>
	  <td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="dataBack">
		  <tr>
			<td width="34"><img src="<?=APPLICATION_SITEADMIN_URL?>images/cor_data_bot_l.gif" alt="bl" /></td>
			<td class="botborder" >&nbsp;</td>
			<td width="19"><img src="<?=APPLICATION_SITEADMIN_URL?>images/cor_data_bot_r.gif" alt="br" /></td>
		  </tr>
	  </table></td>
	</tr>
</table>
